package JavaBase.Polymorphism;

public class Rectangle extends Shape{

    private double length;
    private double width;

    public Rectangle(double length,double width)
    {
        this.length=length;
        this.width=width;
    }

    public double getLength() {
        return length;
    }

    public void setLength(double length) {
        this.length = length;
    }

    public double getWidth() {
        return width;
    }

    public void setWidth(double width) {
        this.width = width;
    }
    public void area()
    {
        if(this.width<=0||this.length<=0)
        {
            System.out.println("取值范围无意义！！！");
            System.exit(1);
        }
        System.out.println("长："+this.length+"\n宽："+this.width+"\n矩形的面积："+
                (this.length*this.width));
    }
}
